package register
{{$Namespace := .Namespace}}
import (
    {{range $aggName, $agg := .Aggregates}}
    {{$agg.FileName}}_api "{{$Namespace}}/pkg/cmd-service/userinterface/rest/{{$agg.FileName}}/facade"
    {{- end }}
	"github.com/liuxd6825/dapr-go-ddd-sdk/restapp"
)

// 所有要注册的控制器
var _controllers = make([]restapp.Controller, 0)

//
// GetRegisterController
// @Description: 注册的控制器
// @return *[]restapp.Controller
//
func GetRegisterController() []restapp.Controller {
	return _controllers
}

//
// AddController
// @Description:  添加要注册的控制器
// @param controllers
//
func AddController(controllers ...restapp.Controller) {
	for _, ctl := range controllers {
		if ctl != nil {
			_controllers = append(_controllers, ctl)
		}
	}
}

//
//  initController
//  @Description: 初始化控制器
//
func initController() {
    {{- range $aggName, $agg := .Aggregates}}
    AddController({{$agg.FileName}}_api.New{{$agg.Name}}CommandApi())
    {{- range $entityName, $entity := $agg.Entities}}
    AddController({{$agg.FileName}}_api.New{{$entity.Name}}CommandApi())
    {{- end }}
    {{- end }}
}
